<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>cutPredetermine 切位预定</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<link rel="stylesheet" href="../css/less/common_less.css" />
	<style>
		.Dolo_searchPanle p span{
			margin-left:20px;
		}
		.Dolo_searchPanle p span input{
			width:180px;
			height:22px;
			border:1px solid #e0e0ea;
			border-radius:2px;
			margin-left:5px;
			padding-left:10px;
		}
		select{
			height:24px;
			width:100px;
			border:1px solid #e0e0ea;
			border-radius:2px;
			font-family:"微软雅黑";
		}
		.querySpan {
			float: right;
			margin-right: 20px;
			margin-top: 11px;
		}		
		.datePanle{
			height:50px;
			width:1140px;
			margin-left:4px;
			line-height:50px;
		}
		.datePanle span{
			display:inline-block;
			width:220px;
			text-align:center;
			cursor:pointer;
			float:left;
		}
		.datePanle span:hover{
			background:white;
			color:#00aa98;
		}
		.dataPanle{
			width:1140px;
			margin-left:4px;
			background:white;
			
		}
		table{
			width:1140px;
		}
		tr{
			border-bottom:4px solid #eeeeee;
		}
		td{
			height:50px;
		}
		.buleBottomBorder{
			border-bottom:3px solid #00aa98;
		}
		.connectImg{		
			background:url("../img/pricePlan/connect.png") no-repeat;		
		}
		.exchangeAirportCode{
			cursor:pointer;
			font-size:14px;
		}
		
		.theadtr{
			background:white;
			z-index:1000;
		}
		.theadtr th:nth-of-type(1),.clear tr td:nth-of-type(1){
			width:140px;	
		}
		.theadtr th:nth-of-type(2),.clear tr td:nth-of-type(2){
			width:250px;	
		}
		.theadtr th:nth-of-type(3),.clear tr td:nth-of-type(3){
			width:250px;	
		}
		.theadtr th:nth-of-type(4),.clear tr td:nth-of-type(4){
			width:150px;	
		}
		.theadtr th:nth-of-type(5),.clear tr td:nth-of-type(5){
			width:100px;	
		}
		.theadtr th:nth-of-type(6),.clear tr td:nth-of-type(6){
			width:100px;	
		}
		.theadtr th:nth-of-type(7),.clear tr td:nth-of-type(7){
			width:150px;	
		}
		.fixedClass{
			width:1140px;
			border-top:6px solid #f1f1f1;
			border-bottom:4px solid #f1f1f1;
		}
		.font14px{
			font-size: 14px;
		}
		.multiTrip{
			background:#00aa98;
			padding:1px 2px;
			border-radius:3px;
			font-size:10px;
			color:white;
			margin-left:4px;
		}
		.flightNo{
			position:relative;
		}
		.signBox{
			height:20px;
			position:absolute;
			top:5px;
			text-align:left;
		}
		.connectImg{
			display:inline-block;
			padding:10px;
			margin-left:5px;
		}
	</style>
	<body>
		<div class='Dolo_searchPanle f60666'>
			<p>
				<span>出发<input uppercase class="deptCity autocomplete" type='text'/></span>
				<span class='iconfont exchangeAirportCode'>&#xe719;</span>
				<span>到达<input uppercase class="arrCity autocomplete" type='text'/></span>
				<span>舱位
					<select class='seatClass'>
						<option value='F'>头等舱</option>
						<option value='C'>商务舱</option>
						<option value='Y'>经济舱</option>
					</select>
				</span>

		<!--		<i class='query'></i>  -->
				<button class="querySpan searchBtn"><i class="iconfont setIcon">&#xe661;</i>查询</button>
			</p>
		</div>
		<div class='datePanle'>
			
		</div>
		<div class='dataPanle'>
			<table>
				<tr class="theadtr aaaaaa" style='height:40px;line-height:40px;'>
					<th>航班号</th>
					<th>出发</th>
					<th>到达</th>
					<th>座位数</th>
					<th>舱位</th>					
					<th>行程天数</th>
					<th>单价含税(张)</th>
				</tr>
				<tbody class='clear'>
				
				</tbody>
			</table>
			
		</div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>
		<script type="text/javascript" src="../js/jquery.autocomplete.js" ></script>
		<script type="text/javascript" src="../js/angular.js" ></script>
		<script type="text/javascript" src="../js/angular-route.js" ></script>
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<script>
			
//____________________________________________________________________________机场联想
			
			$.ajax({
				type:"get",
				url:"../Airapt?pageSize=100000&pageNum=1&temp="+Math.random(),
				dataType:"json",
				success:function(data){	
					var autocompleteData = data.data.list; 
					$('.autocomplete').autocomplete({
					    lookup: autocompleteData,
					    autoSelectFirst:true,
					    onSelect: function (suggestion) {		   
					    }
					});
				}
			})

			
//____________________________________________________________________________			
			$(".querySpan").click(function(){
				getAjax()
			})
			function getAjax(){		
				if(/\((.)+?\)/.test($(".deptCity").val())){//获取出发机场三字码
					var deptCity = $(".deptCity").val().slice(-5).split("(")[1].split(")")[0];
				}else{
					var deptCity = ($(".deptCity").val()).toUpperCase();
				}
				if(/\((.)+?\)/.test($(".arrCity").val())){//获取到达机场三字码
					var arrCity = $(".arrCity").val().slice(-5).split("(")[1].split(")")[0];
				}else{
					var arrCity = ($(".arrCity").val()).toUpperCase();
				}	
				if(deptCity==""||arrCity==""){
					layer.msg("请输入完整的查询信息",{icon:2})
					return false;
				}
			//	var deptCity = $(".deptCity").val();
			//	var arrCity = $(".arrCity").val();
				var seatClass = $(".seatClass").val();
				var preDate = new Date().getTime();//+172800000;
				var year = new Date(preDate).getFullYear();
				var month = new Date(preDate).getMonth()+1;
				var day = new Date(preDate).getDate();
				var deptStartDate = year+"-"+addZero(month)+"-"+addZero(day);
				layer.load()
				$.ajax({
					type:"get",
					url:'../shopping/api/getCharterShopping?deptCity='+deptCity+'&source=pss&arrCity='+arrCity+'&seatClass='+seatClass+'&deptStartDate='+deptStartDate+'&charterType=QW&routingType=RT&temp='+Math.random(),
					dataType:"json",
					async:true,
					success:function(data){	
						layer.closeAll('loading');
						$(".clear").empty();
						$(".datePanle").empty();
						data_=data;
						if(data.status=="1002"){
							layer.alert(data.message)
							return false;
						}												
						var str1="";						
						labelArr = [];
						for(var i=0;i<data.data.length;i++){
							var multiTrip = "";
							if(data.data[i].multiTrip){
								multiTrip += "<i class='multiTrip'>转</i>"
							}
							str1+="<span index="+i+" class='label'>"+data.data[i].label+multiTrip+"</span>"
							labelArr.push(data.data[i].label)
						}
						$(".datePanle").append(str1);
						
					}
				})
			}
			
			
			
			$(".datePanle").delegate(".label","click",function(){					
				$(this).addClass("buleBottomBorder").siblings().removeClass('buleBottomBorder');							
				var str2="";
				var index = $(this).attr("index");			
				for(var i=0;i<data_.data[index].products.length;i++){
					var serialBorder = true;//往返程的分割	
					var segmentsLength = data_.data[index].products[i].segments.length;
					for(var j=0;j<segmentsLength;j++){
						var length = data_.data[index].products[i].segments.length;
						var strArrDate = data_.data[index].products[i].segments[j].arrDate;
						var strDepDate = data_.data[index].products[i].segments[j].depDate;
						var depApCn = data_.data[index].products[i].segments[j].depApCn;
						var depAp = data_.data[index].products[i].segments[j].depAp;
						var depTerminal = data_.data[index].products[i].segments[j].depTerminal;
						var depDate = data_.data[index].products[i].segments[j].depDate;
						var depTime = data_.data[index].products[i].segments[j].depTime;
						var arrApCn = data_.data[index].products[i].segments[j].arrApCn;
						var arrAp = data_.data[index].products[i].segments[j].arrAp;
						var arrTerminal = data_.data[index].products[i].segments[j].arrTerminal;
						var arrDate = data_.data[index].products[i].segments[j].arrDate;
						var arrTime = data_.data[index].products[i].segments[j].arrTime;						
						var multiTrip = data_.data[index].products[i].multiTrip;
						
						//联运图标
						var connectImg = "<div class='signBox'>";
						if(data_.data[index].products[i].connectFltInfo){   
							connectImg +="<span class='connectImg'></span>";
						}
						connectImg += "</div>";
						//中转
						if(multiTrip){
							var com = "<td class='faa000 flightNo'>"+connectImg+data_.data[index].products[i].segments[j].flightNo+"</td>"+
						 			  "<td><span class='f262929 font14px'>"+depApCn +"("+depAp+")<span class='f00aa99'>"+depTerminal+"</span></span></br><span class='f00aa99' style='font-weight:bold'>"+depDate +"&nbsp;&nbsp;<span class='f262929' style='font-weight:normal;'>"+ depTime+"</span></span></td>"+
						 			  "<td><span class='f262929 font14px'>"+arrApCn +"("+arrAp+")<span class='f00aa99'>"+arrTerminal+"</span></span></br><span class='f00aa99' style='font-weight:bold'>"+arrDate +"&nbsp;&nbsp;<span class='f262929' style='font-weight:normal;'>"+ arrTime+"</span></span></td>"+
						 			  "<td class='f262929 font14px'>"+data_.data[index].products[i].productSeats+"</td>";
			
						 	if(segmentsLength==1){
						 		str2+="<tr>"+com;
						 		
						 	}else if(serialBorder&&data_.data[index].products[i].segments[j+1].serial=="2"){
								serialBorder = false;
								str2+="<tr>"+com;										
							}else{
								if(j==(segmentsLength-1)){
									str2+="<tr>"+com;
								}else{
									str2+="<tr style='border:none'>"+com;
								}
							}																									
						}else{
							str2+="<tr>"+
									"<td class='faa000 flightNo'>"+connectImg+data_.data[index].products[i].segments[j].flightNo+"</td>"+
						 			"<td><span class='f262929 font14px'>"+depApCn +"("+depAp+")<span class='f00aa99'>"+depTerminal+"</span></span></br><span class='f00aa99' style='font-weight:bold'>"+depDate +"&nbsp;&nbsp;<span class='f262929' style='font-weight:normal;'>"+ depTime+"</span></span></td>"+
						 			"<td><span class='f262929 font14px'>"+arrApCn +"("+arrAp+")<span class='f00aa99'>"+arrTerminal+"</span></span></br><span class='f00aa99' style='font-weight:bold'>"+arrDate +"&nbsp;&nbsp;<span class='f262929' style='font-weight:normal;'>"+ arrTime+"</span></span></td>"+
						 			"<td class='f262929 font14px'>"+data_.data[index].products[i].productSeats+"</td>"
					
						} 														 
						if(j==0){
							str2+=  "<td class='f262929 font14px' rowspan="+length+">"+commomFun.cabinStatusStr(data_.data[index].products[i].segments[j].cabinCode)+"</td>"+			  		
							  		"<td class='f262929 font14px' rowspan="+length+">"+commomFun.toEmptyString(data_.data[index].products[i].journeyDays)+"</td>"+
							  		"<td class='font14px' rowspan="+length+"><span class='fa2828'>"+(data_.data[index].products[i].fare.adultPrice+data_.data[index].products[i].fare.adultTFC) +"</span> <span style='color:black;'>"+ commomFun.toEmptyString(data_.data[index].products[i].fare.currency)+"</span></td>"					      			
						}
							str2+="</tr>";							  								  
					}					
				}
				$(".clear").empty();
				$(".clear").append(str2);
			})	
//____________________________________thead的固定________________________________
		$(window).scroll(function(){
			if($(document).scrollTop()>60){
				$(".theadtr").css({
					"position":"fixed",
					"top":"-0px"					
				})
				$(".theadtr").addClass("fixedClass")
			}else{
				$(".theadtr").css({
					"position":"static"
				})
				$(".theadtr").removeClass("fixedClass")
			}
		});			
//_____________________________________________出发到达机场条件互换________________
			$(".exchangeAirportCode").click(function(){
				var exchangeVar = $(".deptCity").val();
				$(".deptCity").val($(".arrCity").val());
				$(".arrCity").val(exchangeVar);
			})

//___________________________________________加0函数__________________________


			function addZero(x){
				if(x>9){
					return x;
				}else{
					return "0"+x;
				}
			}

		</script>
	</body>
</html>
